package com.bizfx.utils
{
	import flash.external.ExternalInterface;
	
	public class WebUtils
	{
		public function WebUtils()
		{
		}
		
		public static function getRequestString(name:String):String {
			var query:String = ExternalInterface.call("window.location.search.substring", 1);
			if(query) {
				var pairs:Array = query.split("&");
				for(var i:uint=0; i < pairs.length; i++) {
					var pos:int = pairs[i].indexOf("=");
					if(pos != -1) {
						var argname:String = pairs[i].substring(0, pos);
						var value:String = pairs[i].substring(pos+1);
						
						if (argname == name) {
							return value;
						}
					}
				}
			}
			return "";
		}
		
		public static function getRequestStrings():Object {
			var params:Object = {};
			var query:String = ExternalInterface.call("window.location.search.substring", 1);
			if(query) {
				var pairs:Array = query.split("&");
				for(var i:uint=0; i < pairs.length; i++) {
					var pos:int = pairs[i].indexOf("=");
					if(pos != -1) {
						var argname:String = pairs[i].substring(0, pos);
						var value:String = pairs[i].substring(pos+1);
						
						params[argname] = value;
					}
				}
			}
			return params;
		}
	}
}